import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:intl/intl.dart';
class OrderDetail extends StatefulWidget {
  Map arguments;
  OrderDetail({Key key,this.arguments}) : super(key: key);

  @override
  _OrderDetailState createState() => _OrderDetailState(arguments:this.arguments);
}

class _OrderDetailState extends State<OrderDetail> {
  Map arguments;
   //int aTime;
  String aTime;
  String t;//发货时间
  String c;//创建时间
  String p;//支付时间
  _OrderDetailState({this.arguments});
 
  @override
  void initState(){
    super.initState();
  _getTime();
  }
  void _getTime(){
    setState(() {
        print(arguments['id']['lives']);
        aTime=arguments['id']['lives'];
        var aTime1=arguments['id']['createtiem'];
        var aTime2=arguments['id']['paytiem'];
        var endtime = DateTime.fromMillisecondsSinceEpoch(int.parse(aTime));
        var statime=DateTime.fromMillisecondsSinceEpoch(int.parse(aTime1));
        var paytime=DateTime.fromMillisecondsSinceEpoch(int.parse(aTime2));
           t = endtime.toLocal().toString().substring(0, 16);
           c=statime.toLocal().toString().substring(0, 16);
           p=paytime.toLocal().toString().substring(0, 16);
    });
  }
 
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar: AppBar(title:Text('订单详情'),  backgroundColor: Colors.orangeAccent,),
        body: Container(
          width: ScreenUtil().setWidth(750),
          child: Column(
            children: <Widget>[
              Container(
                width: ScreenUtil().setWidth(750),
                height: ScreenUtil().setHeight(200),
               decoration: BoxDecoration(
                  color: Colors.orangeAccent,
               ),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: <Widget>[
                    Center(child: arguments['id']['type']==2?Text('卖家正在备货',style: TextStyle(color:Colors.white,fontSize:16,fontWeight: FontWeight.w600),):
                    (arguments['id']['type']==3?Text('卖家已发货',style: TextStyle(color:Colors.white,fontSize:16,fontWeight: FontWeight.w600),):
                    Text('交易成功',style: TextStyle(color:Colors.white,fontSize:16,fontWeight: FontWeight.w600),)),),
                    Center(child: arguments['id']['type']==3?Text('预计${t}',style: TextStyle(color:Colors.white),):Text('',style: TextStyle(color:Colors.white),),)
                  ],
                ),
              ),
              Container(
                child: Card(
                  child: Column(
                    children: <Widget>[
                      ListTile(
                       leading: Icon(Icons.call_made),
                  title: Text('设置',style: TextStyle(color:Colors.black54),),
                  trailing: Icon(Icons.chevron_right),
                  onTap: (){
                print('设置');
              },
              ),
           new Divider(),
            ListTile(
            leading: Icon(Icons.location_on),
              title: Text('${arguments['id']['user']}${arguments['id']['userphone']}',style: TextStyle(color:Colors.black54),),
              subtitle: Text('${arguments['id']['address']}'),
             // trailing: Icon(Icons.settings),
              onTap: (){
            Navigator.pushNamed(context, '/map');
              },
              ),
           new Divider(),
                    ],
                  ),
                ),
              ),
              Container(
                child: Card(
                  child: Column(
                    children: <Widget>[
                        Container(
                          width: ScreenUtil().setWidth(730),
                          height: ScreenUtil().setHeight(200),
                          child: Row(
                            children: <Widget>[
                              Container(
                                width: ScreenUtil().setWidth(180),
                                height: ScreenUtil().setHeight(180),
                                child: Image.network('${arguments['id']['images']}',fit: BoxFit.cover,),
                              ),
                              Container(
                                width: ScreenUtil().setWidth(420),
                                height: ScreenUtil().setHeight(180),
                                child: ListTile(
                                  title: Text('${arguments['id']['goodsname']}',maxLines: 1,overflow: TextOverflow.clip,style: TextStyle(fontSize:12),),
                                  subtitle: Text('${arguments['id']['size']}',style: TextStyle(fontSize:10),),
                                ),
                              ),
                              Expanded(
                                child: Container(
                                  width: ScreenUtil().setWidth(150),
                                  height: ScreenUtil().setHeight(180),
                                child: ListTile(
                                  title: Text('￥${arguments['id']['price']}',style: TextStyle(fontSize: 10),),
                                  subtitle: Text('X${arguments['id']['count']}',style: TextStyle(fontSize: 10),),
                                ),
                              ))
                            ],
                          ),
                        )
                    ],
                  ),
                ),
              ),
              //订单信息
              Container(
                width: ScreenUtil().setWidth(750),
                padding: EdgeInsets.all(10),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text('订单信息',style: TextStyle(fontSize: 16,fontWeight: FontWeight.w500),),
                    Row(
                      children: <Widget>[
                        Text('获得积分:',style: TextStyle(fontSize: 12),),
                        SizedBox(width:50),
                        Text('结算中',style: TextStyle(fontSize: 12),)
                      ],
                    ),
                    SizedBox(height:10),
                    Row(
                      children: <Widget>[
                        Text('订单编号:',style: TextStyle(fontSize: 12),),
                        SizedBox(width:50),
                        Text('${arguments['id']['ordernumber']}',style: TextStyle(fontSize: 12),)
                      ],
                    ),
                    SizedBox(height:10),
                    Row(
                      children: <Widget>[
                        Text('创建时间:',style: TextStyle(fontSize: 12),),
                        SizedBox(width:50),
                        Text('${c}',style: TextStyle(fontSize: 12),)
                      ],
                    ),
                    SizedBox(height:10),
                    Row(
                      children: <Widget>[
                        Text('付款时间:',style: TextStyle(fontSize: 12),),
                        SizedBox(width:50),
                        Text('${p}',style: TextStyle(fontSize: 12),)
                      ],
                    ),
                    SizedBox(height:10),
                    Row(
                      children: <Widget>[
                        Text('发货时间:',style: TextStyle(fontSize: 12),),
                        SizedBox(width:50),
                        Text('${t}',style: TextStyle(fontSize: 12),)
                      ],
                    ),
                    SizedBox(height:10),
                    Row(
                      children: <Widget>[
                        Text('投诉商家:',style: TextStyle(fontSize: 12),),
                        SizedBox(width:50),
                        Text('交易完成可申请',style: TextStyle(fontSize: 12),)
                      ],
                    ),
                    SizedBox(height:10),
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}